//
//  LSZMembersFamilyViewController.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/11/29.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZMembersFamilyViewController.h"

@interface LSZMembersFamilyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong,nonatomic)  UITableView *tableViewMembers;
@property (strong,nonatomic) LSZInquiryPoorHouseholdsManager * poorHouseholdsManager;
@end

@implementation LSZMembersFamilyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"家庭成员";
    [self.view addSubview:self.tableViewMembers];
//    [self.tableViewMembers registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    [self.tableViewMembers registerNib:[UINib nibWithNibName:@"LSZMembersTableViewCell" bundle:nil] forCellReuseIdentifier:@"LSZMembersTableViewCell"];
    [self getMembersFamilyData];
}
-(void)getMembersFamilyData
{
    [LSZRequestDicData initWithMembersPoorFamilies:self.householdNumber :^(BOOL isOK, NSString * string, LSZInquiryPoorHouseholdsManager * manager) {
        if (isOK == YES) {
            self.poorHouseholdsManager = manager;
            [self.tableViewMembers reloadData];
        }else{
            if ([string isEqualToString:@"重复登录"]) {
                [LSZPublicClassDataToll RepeatLoginInterfaceJump:self.view fromVC:@"LSZLiteratureViewController"];
            }else{
                [LSZPublicClassDataToll initWithAlertKuangView:self.view string:string];
            }
        }
    }];
 
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.poorHouseholdsManager.mutArrayData.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.001;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZMembersTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZMembersTableViewCell" forIndexPath:indexPath];
    if (self.poorHouseholdsManager.mutArrayData.count > indexPath.row) {
        LSZInquiryPoorHouseholdsMg * manager = nil;
        manager = self.poorHouseholdsManager.mutArrayData[indexPath.row];
        cell.nameLab.text = manager.name;
        cell.ageLab.text = @"0岁";
        cell.relationshipLab.text = manager.relation;
    }
    cell.textLabel.textColor = RGBColor(51, 51, 51);
    cell.textLabel.font = FONT_(14);
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.poorHouseholdsManager.mutArrayData.count > indexPath.row) {
        LSZInquiryPoorHouseholdsMg * manager = nil;
        manager = self.poorHouseholdsManager.mutArrayData[indexPath.row];
        LSZMemberInformationViewController * vc = [[LSZMemberInformationViewController alloc]init];
        vc.inquiryPoorHouseholdsMg = manager;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(UITableView *)tableViewMembers
{
    if (_tableViewMembers == nil) {
        _tableViewMembers = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height) style:UITableViewStyleGrouped];
        _tableViewMembers.delegate = self;
        _tableViewMembers.dataSource = self;
        _tableViewMembers.estimatedRowHeight=0;
        _tableViewMembers.estimatedSectionFooterHeight =0;
        _tableViewMembers.estimatedSectionHeaderHeight =0;
        [_tableViewMembers setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        [self.view addSubview:_tableViewMembers];
    }
    return _tableViewMembers;
}
@end
